<template>
	<view class="home">
		<!-- 自定义导航栏 -->
		<navbar></navbar>
		<tab :list="tabList"  @onTab="tab" :tabIndex="tabIndex"></tab>
		<!-- <view class="scroll">
			<scroll-view class="list-scroll" scroll-y enable-flex="true">
				<view>
					<view v-for="(item,index) in 100" :key="index">
						{{item}}nmls
						
					</view>
				</view>
			</scroll-view>
		</view> -->
		
		<!-- <list-scroll>
			 <list-card mode ="base"></list-card>
			  <list-card mode ="column"></list-card>
			   <list-card mode ="image"></list-card>
		</list-scroll> -->
		<view class="home-list">
				<list :tab="tabList" @change="change" :activeIndex="activeIndex"></list>
		</view>
	</view>
</template>

<script>
	// easyCom components/组件名/组件名.vue 局部引入
	export default {
		data() {
			return {
				title: 'Hello',
				tabList: [],
				tabIndex:0,
				activeIndex:0
			}
		},
		onLoad() {
			uni.$on('labelChange',() => {
				// console.log("nmb")
				this.tabList = []
				this.tabIndex = 0
				this.activeIndex = 0
				this.getLabel()
			})
			this.getLabel()
		},
		methods: {
			tab({data,index}){
				// console.log(data,index);
				this.activeIndex = index;
			},
			getLabel() {
				// 调用云函数方法
				this.$api.get_label({
				}).then((res) => {
					console.log('res' ,res)
					const {
						data
					} = res
					data.unshift({
						name:'全部'
					})
					this.tabList = data
					// 	console.log(this.tabList);
				})

			},
			change(current){
				this.tabIndex = current;
				this.activeIndex = current
				// console.log(current)
			}
		}
	}
</script>

<style lang="scss">
	page {
		height: 100%;
		display: flex;
	}
	.home  {
		display: flex;
		flex-direction: column;
		flex: 1;
		// border: 1px red solid;
		overflow: hidden;
		.home-list{
			flex: 1;
			box-sizing: border-box;
			// border: 1px solid yellow;
		}
	} 

</style>